feat(sdk): add turn.failed system event support#119
Merged
Conversation
Adds a new `turn.failed` SystemEvent variant alongside the existing `turn.started` / `turn.completed` / `broker.error` events, with parsing, typed timeline guards, and ACP stream-level handling. - shared: new `SystemEvent` variant `turn.failed`, raw-event helper `isTurnFailedAxonEvent`, parser in `tryParseSystemEvent`, narrowed `TurnFailedTimelineEvent` + `isTurnFailedEvent` guard. - acp/claude: re-export the new type and guard from each module's timeline-event-guards barrel; refresh JSDoc on the system-event lists. - acp/axon-stream: when a `turn.failed` SYSTEM_EVENT arrives, reject every in-flight JSON-RPC request with a `-32000` error carrying the failure message and `event_type: "turn.failed"` data, but keep the SSE loop alive so subsequent prompts on the same session can flow. - docs: update `sdk/AGENTS.md` system-event references. Co-authored-by: Cursor <cursoragent@cursor.com>
dines-rl
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
turn.failedSystemEvent variant alongside the existingturn.started/turn.completed/broker.errorevents, with parsing, typed timeline guards, and ACP stream-level handling.SystemEventvariantturn.failed, raw-event helperisTurnFailedAxonEvent, parser intryParseSystemEvent, narrowedTurnFailedTimelineEvent+isTurnFailedEventguard.timeline-event-guardsbarrel; refresh JSDoc on the system-event lists.turn.failedSYSTEM_EVENT arrives, reject every in-flight JSON-RPC request with a-32000error carrying the failure message andevent_type: \"turn.failed\"data, but keep the SSE loop alive so subsequent prompts on the same session can flow.sdk/AGENTS.mdsystem-event references.Test plan
bun run checkpassesbun run typecheckpassesbun run buildpassesbun run testpasses (500 tests, 19 files)axon-streambehaviours: single-pending rejection, multi-pending rejection, raw-payload fallback, stream-stays-alive after failure, and the no-op-when-no-pending case.Made with Cursor